From 00f028123bc2b13d02a67eee50c8f352a60f9943 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 31 Mar 2008 02:51:05 +0000 Subject: [PATCH] Don't hose if we replace a string with a string that's a supserset of the origin (e.g. in vcf if we replace ; with \\;). git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@3154 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gpsbabel/util.c b/gpsbabel/util.c index d76b7ea3b..17807097f 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -1104,10 +1104,14 @@ char * gstrsub(const char *s, const char *search, const char *replace) { char *o = xstrdup(s); - - while (strstr(o, search)) { + char *tsearch = o; + // The tsearch silliness here is in case we decide to replace a string + // with a string that's a superset of that string. Replacing ";" + // with "\\;" in the vcf writer is our problem child. + while ((tsearch = strstr(tsearch, search))) { char *oo = o; o = strsub(o, search, replace); + tsearch = tsearch + strlen(replace); xfree(oo); } -- 2.30.2